<template>
  <div>
    <el-row class="margintop20">
      <el-col :span="10" class="margintop20">
        <el-form :model="form" :rules="rules" ref="myForm" label-width="100px" class="myform">
          <el-form-item label="职位：" prop="roleid">
            <el-select v-model="form.roleid">
              <el-option
                v-for="(role,i) in roleList"
                :key="i"
                :label="role.label"
                :value="role.value"
              ></el-option>
            </el-select>
          </el-form-item>

          <el-form-item label="薪资：" prop="money">
            <el-input v-model="form.money" type="number"></el-input>
          </el-form-item>

          <el-form-item>
            <el-button type="info" class="width100" @click="addForm">添加</el-button>
          </el-form-item>
        </el-form>
      </el-col>
    </el-row>
  </div>
</template>


<script>
import { roleList, statusList } from "@/utils";
import { addmoney } from "@/api";
export default {
  data() {
    return {
      form: {},
      roleList,
      rules: {
        roleid: [
          { required: true, message: "请选择职位", trigger: "change" },
        ],
        money: [
          { required: true, message: "请选择薪资", trigger: "change" },
        ],
      },
    };
  },
  methods: {
    addForm() {
        this.$refs.myForm.validate(valid=>{
            if(valid){
                addmoney(this.form)
                .then(res=>{
                    if(res.type){
                        this.$router.push({name:'moneylist'})
                    }
                })
            }
        })
    },
  },
};
</script>